<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-gtype-add">
			<div class="form-group">	
				<label class="col-sm-3 control-label">分类名称：</label>
				<div class="col-sm-8">
					<input id="gtypeName" name="gtypeName" class="form-control" type="text">
				</div>
			</div>
			
			<div class="form-group">	
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<input id="remark" name="remark" class="form-control" type="text">
				</div>
			</div>
			
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "gxgw_modules/gtype"
		$("#form-gtype-add").validate({
			rules:{
				gtypeName:{
					required:true,
					minlength: 1,
        			maxlength: 256,
        			remote: {
                        url: ctx + "gxgw_modules/gtype/checkGtypeNameUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                        	name : function() {
                                return $.common.trim($("#gtypeName").val());
                            }
                        },
                        dataFilter: function(data, type) {
                           
                        	return $.validate.unique(data);
                        }
				     }
		        },
			},
		messages: {
            "gtypeName": {
                remote: "商品种类名称已经存在"
            }
           },
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/add", $('#form-gtype-add').serialize());
	        }
	    }
	</script>
</body>
</html>
